package service

import (
	"guliedu/model"
	"guliedu/repository"
)

type IEduSubjectService interface {
	SelectAllSubjectByOne() ([]model.EduSubject, error)
	SelectOneSubject() ([]model.EduSubject, error)
	SelectSubjectByTitle(title string) (*model.EduSubject, error)
	Insert(s *model.EduSubject) error
	Select() ([]model.EduSubject, error)
	SelectByCourseID(id string) (*model.EduSubject, error)
}

func NewIEduSubjectService() IEduSubjectService {
	return &EduSubjectService{EduSubjectService: repository.NewIEduSubjectRepository()}
}

type EduSubjectService struct {
	EduSubjectService repository.IEduSubjectRepository
}

func (t *EduSubjectService) SelectSubjectByTitle(title string) (*model.EduSubject, error) {
	return t.EduSubjectService.SelectSubjectByTitle(title)
}

func (t *EduSubjectService) Insert(s *model.EduSubject) error {
	return t.EduSubjectService.Insert(s)
}

func (t *EduSubjectService) SelectOneSubject() ([]model.EduSubject, error) {
	return t.EduSubjectService.SelectOneSubject()
}

func (t *EduSubjectService) SelectAllSubjectByOne() ([]model.EduSubject, error) {
	return t.EduSubjectService.SelectAllSubjectByOne()
}

func (t *EduSubjectService) Select() ([]model.EduSubject, error) {
	return t.EduSubjectService.Select()
}

func (t *EduSubjectService) SelectByCourseID(id string) (*model.EduSubject, error) {
	return t.EduSubjectService.SelectByCourseID(id)
}
